home *** CD-ROM | disk | FTP | other *** search
/ PC World 2006 September / PCWorld_2006-09_cd.bin / v cisle / flyakite / FlyakiteOSX v3.5.exe / $DESKTOP / FlyakiteOSX v3.5 Source / Functions.nsi < prev    next >
Text File  |  2006-02-25  |  11KB  |  324 lines

  1. #==========================================
  2. # GET SIZE OF FILE
  3. #==========================================
  4.     !macro GetFileSize UN
  5.     Function "${UN}GetFileSize"
  6.       Exch $0
  7.       Push $1
  8.       FileOpen $1 $0 "r"
  9.       FileSeek $1 0 END $0
  10.       FileClose $1
  11.       Pop $1
  12.       Exch $0
  13.     FunctionEnd
  14.     !macroend
  15.     !insertmacro GetFileSize ""
  16.  
  17.  
  18.  
  19. /*
  20. #==========================================
  21. # CLOSE WFP DIALOGS
  22. #==========================================
  23.     !macro CloseWFP UN
  24.     Function "${UN}CloseWFP"
  25.       LOOP:
  26.       FindWindow $0 "" "Windows File Protection"
  27.       IntCmp $0 0 DONE
  28.       IsWindow $0 0 DONE
  29.       System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
  30.  
  31.       FindWindow $0 "" "Windows File Protection"
  32.       System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_COMMAND},6,0)'
  33.       Sleep 200
  34.       Goto LOOP
  35.       DONE:
  36.     FunctionEnd
  37.     !macroend
  38.     !insertmacro CloseWFP ""
  39.     !insertmacro CloseWFP "un."
  40. */
  41.  
  42.  
  43.  
  44. #==========================================
  45. # CHECK IF USER SELECTED ANY OPTIONS
  46. #==========================================
  47.     Function "CheckForSelections"
  48.       !insertmacro SectionFlagIsSet ${SYSTEMFILES} ${SF_SELECTED} END ""
  49.       !insertmacro SectionFlagIsSet ${SYSTEMFILES} ${SF_PSELECTED} END ""
  50.       !insertmacro SectionFlagIsSet ${EXTRAS} ${SF_SELECTED} END ""
  51.       !insertmacro SectionFlagIsSet ${EXTRAS} ${SF_PSELECTED} END ""
  52.       !insertmacro SectionFlagIsSet ${SKINS} ${SF_SELECTED} END ""
  53.       !insertmacro SectionFlagIsSet ${SKINS} ${SF_PSELECTED} END ""
  54.       !insertmacro SectionFlagIsSet ${TWEAKS} ${SF_SELECTED} END ""
  55.       !insertmacro SectionFlagIsSet ${TWEAKS} ${SF_PSELECTED} END ""
  56.       !insertmacro SectionFlagIsSet ${SOFTWARE} ${SF_SELECTED} END ""
  57.       !insertmacro SectionFlagIsSet ${SOFTWARE} ${SF_PSELECTED} END ""
  58.       MessageBox MB_OK|MB_ICONEXCLAMATION "You did not select any items.  Please look through the options and choose what you would like to install." /SD IDOK
  59.       Abort
  60.       END:
  61.     FunctionEnd
  62.  
  63.  
  64.     !macro un.CheckForSelections UN
  65.     Function "${UN}CheckForSelections"
  66.       !insertmacro SectionFlagIsSet ${un.REMOVEUNINSTALLER} ${SF_SELECTED} "" NOREMOVEUNINSTALLER
  67.       !insertmacro SectionFlagIsSet ${un.SYSTEMFILES} ${SF_SELECTED} CANTPROCEED ""
  68.       !insertmacro SectionFlagIsSet ${un.SYSTEMFILES} ${SF_PSELECTED} CANTPROCEED ""
  69.       !insertmacro SectionFlagIsSet ${un.EXTRAS} ${SF_SELECTED} CANTPROCEED ""
  70.       !insertmacro SectionFlagIsSet ${un.EXTRAS} ${SF_PSELECTED} CANTPROCEED ""
  71.       !insertmacro SectionFlagIsSet ${un.SKINS} ${SF_SELECTED} CANTPROCEED ""
  72.       !insertmacro SectionFlagIsSet ${un.SKINS} ${SF_PSELECTED} CANTPROCEED ""
  73.       !insertmacro SectionFlagIsSet ${un.SOFTWARE} ${SF_SELECTED} CANTPROCEED ""
  74.       !insertmacro SectionFlagIsSet ${un.SOFTWARE} ${SF_PSELECTED} CANTPROCEED ""
  75.       !insertmacro SectionFlagIsSet ${un.TWEAKS} ${SF_SELECTED} CANTPROCEED ""
  76.       !insertmacro SectionFlagIsSet ${un.TWEAKS} ${SF_PSELECTED} CANTPROCEED ""
  77.       !insertmacro SectionFlagIsSet ${un.EXTRAOPTIONS} ${SF_SELECTED} CANTPROCEED ""
  78.       !insertmacro SectionFlagIsSet ${un.EXTRAOPTIONS} ${SF_PSELECTED} CANTPROCEED ""
  79.       Goto END
  80.       CANTPROCEED:
  81.       MessageBox MB_OK|MB_ICONEXCLAMATION "The 'Remove Uninstaller and Backup Files' item must be uninstalled separately.$\nPlease unselect this item or unselect all other items to proceed." /SD IDOK
  82.       Abort
  83.  
  84.       NOREMOVEUNINSTALLER:
  85.       !insertmacro SectionFlagIsSet ${un.SYSTEMFILES} ${SF_SELECTED} END ""
  86.       !insertmacro SectionFlagIsSet ${un.SYSTEMFILES} ${SF_PSELECTED} END ""
  87.       !insertmacro SectionFlagIsSet ${un.EXTRAS} ${SF_SELECTED} END ""
  88.       !insertmacro SectionFlagIsSet ${un.EXTRAS} ${SF_PSELECTED} END ""
  89.       !insertmacro SectionFlagIsSet ${un.SKINS} ${SF_SELECTED} END ""
  90.       !insertmacro SectionFlagIsSet ${un.SKINS} ${SF_PSELECTED} END ""
  91.       !insertmacro SectionFlagIsSet ${un.SOFTWARE} ${SF_SELECTED} END ""
  92.       !insertmacro SectionFlagIsSet ${un.SOFTWARE} ${SF_PSELECTED} END ""
  93.       !insertmacro SectionFlagIsSet ${un.TWEAKS} ${SF_SELECTED} END ""
  94.       !insertmacro SectionFlagIsSet ${un.TWEAKS} ${SF_PSELECTED} END ""
  95.       !insertmacro SectionFlagIsSet ${un.EXTRAOPTIONS} ${SF_SELECTED} END ""
  96.       !insertmacro SectionFlagIsSet ${un.EXTRAOPTIONS} ${SF_PSELECTED} END ""
  97.       MessageBox MB_OK|MB_ICONEXCLAMATION "You did not select any items.  Please look through the options and choose what you would like to uninstall." /SD IDOK
  98.       Abort
  99.       END:
  100.     FunctionEnd
  101.     !macroend
  102.     !insertmacro un.CheckForSelections "un."
  103.  
  104.  
  105.  
  106. #==========================================
  107. # ALLOW ONLY ONE INSTALLER INSTANCE
  108. #==========================================
  109.     !macro OneInstance UN
  110.       Function "${UN}OneInstance"
  111.         System::Call "kernel32::CreateMutexA(i 0, i 0, t '${PRODUCT_NAME}') i .r0 ?e"
  112.         Pop $0
  113.         StrCmp $0 0 LAUNCH
  114.         StrLen $0 "$(^Name)"
  115.         IntOp $0 $0 + 1
  116.         LOOP:
  117.         FindWindow $1 '#32770' '' 0 $1
  118.         IntCmp $1 0 +4
  119.         System::Call "user32::GetWindowText(i r1, t .r2, i r0) i."
  120.         StrCmp $2 "$(^Name)" 0 LOOP
  121.         System::Call "user32::SetForegroundWindow(i r1) i."
  122.         Abort
  123.         LAUNCH:
  124.       FunctionEnd
  125.     !macroend
  126.     !insertmacro OneInstance ""
  127.     !insertmacro OneInstance "un."
  128.  
  129.  
  130.  
  131. #==========================================
  132. # CHECK IF USER HAS ADMIN RIGHTS
  133. #==========================================
  134.     !macro CheckAdminRights UN
  135.       Function "${UN}CheckAdminRights"
  136.         System::Call "kernel32::GetModuleHandle(t 'shell32.dll') i .s"
  137.         System::Call "kernel32::GetProcAddress(i s, i 680) i .r0"
  138.         System::Call "::$0() i .r0"
  139.         StrCmp "$0" "1" +3
  140.         MessageBox MB_OK "${PRODUCT_NAME} cannot be installed without administrative rights.$\nPlease contact your system administrator." /SD IDOK
  141.         Quit
  142.       FunctionEnd
  143.     !macroend
  144.     !insertmacro CheckAdminRights ""
  145.     !insertmacro CheckAdminRights "un."
  146.  
  147.  
  148.  
  149. #==========================================
  150. # CHECK IF 64BIT
  151. #==========================================
  152.     !macro Check64Bit UN
  153.       Function "${UN}Check64Bit"
  154.         System::Call "kernel32::GetCurrentProcess() i .s"
  155.         System::Call "kernel32::IsWow64Process(i s, *i .r0)"
  156.         StrCmp "$0" "0" +3
  157.         MessageBox MB_OK "${PRODUCT_NAME} cannot be installed on 64-bit versions of Windows.  The installer will now exit." /SD IDOK
  158.         Quit
  159.       FunctionEnd
  160.     !macroend
  161.     !insertmacro Check64Bit ""
  162.  
  163.  
  164.  
  165. #==========================================
  166. # GENERATE RANDOM NUMBER
  167. #==========================================
  168. /*
  169.     !macro RandomNumber UN
  170.       Function "${UN}RandomNumber"
  171.         Exch $0
  172.         Push $1
  173.         System::Call 'kernel32::QueryPerformanceCounter(*l.r1)'
  174.         System::Int64Op $1 % $0
  175.         Pop $0
  176.         Pop $1
  177.         Exch $0
  178.       FunctionEnd
  179.     !macroend
  180. */
  181.  
  182.  
  183. #==========================================
  184. # SHOW SPLASH SCREEN
  185. #==========================================
  186.     !macro ShowSplashScreen UN
  187.       Function "${UN}ShowSplashScreen"
  188.         IfSilent SKIP
  189.         SetOutpath "$PLUGINSDIR"
  190.         File "Assets\Images\Splash\Splash.gif"
  191.         newadvsplash::show 2000 525 525 0xFF00FF "$PLUGINSDIR\Splash.gif"
  192.         SKIP:
  193.       FunctionEnd
  194.     !macroEnd
  195.     !insertmacro ShowSplashScreen ""
  196.  
  197.  
  198.  
  199. #==========================================
  200. # EXTRACT PROJECT SOURCE
  201. #==========================================
  202.       !ifdef ExtractSource
  203.       Function ExtractSource
  204.         Push "BunnyandMe83"
  205.         Push "DefaultValue"
  206.         Call GetParameterValue
  207.         Pop $1
  208.  
  209.         StrCmp $1 "DefaultValue" SKIP
  210.         Banner::show /NOUNLOAD /set 76 "Extracting ${PRODUCT_NAME} Project Files" "Please Wait"
  211.         SetOutPath "$DESKTOP\${PRODUCT_NAME} ${PRODUCT_VERSION} Source"
  212.         File /r "*.*"
  213.         Banner::destroy
  214.         Quit
  215.  
  216.         SKIP:
  217.       FunctionEnd
  218.       !endif
  219.  
  220.  
  221.  
  222. #==========================================
  223. # GET PARENT DIRECTORY
  224. #==========================================
  225.     !macro GetParent UN
  226.       Function "${UN}GetParent"
  227.         Exch $R0
  228.         Push $R1
  229.         Push $R2
  230.         Push $R3
  231.  
  232.         StrCpy $R1 0
  233.         StrLen $R2 $R0
  234.         LOOP:
  235.           IntOp $R1 $R1 + 1
  236.           IntCmp $R1 $R2 GET 0 GET
  237.           StrCpy $R3 $R0 1 -$R1
  238.           StrCmp $R3 "\" GET
  239.           Goto LOOP
  240.         GET:
  241.           StrCpy $R0 $R0 -$R1
  242.           Pop $R3
  243.           Pop $R2
  244.           Pop $R1
  245.           Exch $R0
  246.       FunctionEnd
  247.     !macroend
  248.     !insertmacro GetParent ""
  249.     !insertmacro GetParent "un."
  250.  
  251.  
  252.  
  253. #==========================================
  254. # DELETE ICON CACHE FOR ALL USERS
  255. #==========================================
  256.     !macro DeleteIconCache UN
  257.       Function "${UN}DeleteIconCache"
  258.         StrCpy $R3 ""
  259.         Push "$PROFILE"
  260.         Call ${UN}GetParent
  261.         Pop $R2
  262.         StrCpy $R2 "$R2"
  263.         FindFirst $R0 $R1 "$R2\*"
  264.         StrCmp $R1 "" FINDEND 0
  265.  
  266.         FINDLOOP:
  267.         IfFileExists "$R2\$R1\*.*" 0 NOTDIR
  268.         StrCmp $R1 "." NOTDIR
  269.         StrCmp $R1 ".." NOTDIR
  270.         StrCmp $R1 "All Users" NOTDIR
  271.         StrCmp $R1 "Default User" NOTDIR
  272.         Delete "$R2\$R1\Local Settings\Application Data\*.db"
  273.         ExecCmd::exec '"${INST_TOOLS}\MoveEx.exe" "$R2\$R1\Local Settings\Application Data\IconCache.db"'
  274.  
  275.         NOTDIR:
  276.         FindNext $R0 $R1
  277.         StrCmp $R1 "" FINDEND 0
  278.         Goto FINDLOOP
  279.  
  280.         FINDEND:
  281.         FindClose $R0
  282.  
  283.         #SECOND METHOD TO DELETE ICONCACH.DB FILES
  284.               ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "Local AppData"
  285.               Delete "$0\*.db"
  286.               ExecCmd::exec '"${INST_TOOLS}\MoveEx.exe" "$0\IconCache.db"'
  287.  
  288.               ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "Common AppData"
  289.               Delete "$0\*.db"
  290.               ExecCmd::exec '"${INST_TOOLS}\MoveEx.exe" "$0\IconCache.db"'
  291.       FunctionEnd
  292.     !macroend
  293.     !insertmacro DeleteIconCache ""
  294.     !insertmacro DeleteIconCache "un."
  295.  
  296.  
  297.  
  298. #==========================================
  299. # CHECK 32BIT COLOR DEPTH
  300. #==========================================
  301.     Function "CheckColorDepth"
  302.       System::Call 'user32::GetWindowDC(i $HWNDPARENT) i .r0'
  303.       System::Call 'gdi32::GetDeviceCaps(i $0, i 12) i .r1'
  304.       StrCmp $1 '32' END
  305.       MessageBox MB_YESNO|MB_ICONEXCLAMATION "${PRODUCT_NAME} requires 32 bit color depth to look right. Continue installation anyway?" /SD IDYES IDYES END
  306.       Abort
  307.       END:
  308.     FunctionEnd
  309.  
  310.  
  311.  
  312. #==========================================
  313. # CREATE GLOBALLY UNIQUE IDENTIFIER
  314. #==========================================
  315.     Function CreateGUID
  316.       Push $0
  317.       Push $1
  318.       System::Alloc 16
  319.       System::Call 'ole32::CoCreateGuid(i sr1)'
  320.       System::Call 'ole32::StringFromGUID2(i r1, w .r0, i ${NSIS_MAX_STRLEN})'
  321.       System::Free $1
  322.       Pop $1
  323.       Exch $0
  324.     FunctionEnd